{extend name="common/base"}
{block name='title'}轮播图编辑页面{/block}
{block name='body-type'}ad_edit{/block}
{block name="content"}
        <!-- 内容区域 -->
        <div class="tpl-content-wrapper">

            <div class="row-content am-cf">


                <div class="row">

                    <div class="am-u-sm-12 am-u-md-12 am-u-lg-12">
                        <div class="widget am-cf">
                            <div class="widget-head am-cf">
                                <div class="widget-title am-fl">编辑商品</div>
                                <div class="widget-function am-fr">
                                    <a href="javascript:;" class="am-icon-cog"></a>
                                </div>
                            </div>
                            <div class="widget-body am-fr">

                                <form enctype="multipart/form-data" class="am-form tpl-form-border-form tpl-form-border-br" action="{:Url('admin/goods/update')}?attributes_id={$result.attributes_id}&goods_id={$result.id}" method="post">
                                    <div class="am-form-group">
                                        <label for="user-name" class="am-u-sm-3 am-form-label">商品名称 <span class="tpl-form-line-small-title">Name</span></label>
                                        <div class="am-u-sm-9">
                                            <input type="text" name="name" class="tpl-form-input" id="user-name" placeholder="请输入商品名称" value="{$result.name}">
                                        </div>
                                    </div>                                    
                                    <div class="am-form-group">
                                        <label for="user-weibo" class="am-u-sm-3 am-form-label">商品单价 <span class="tpl-form-line-small-title">Price</span></label>
                                        <div class="am-u-sm-9">
                                            <input type="text" id="link" placeholder="" name="price" value="{$result.price}" placeholder="请输入商品单价">
                                            <div>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="am-form-group">
                                        <label for="user-weibo" class="am-u-sm-3 am-form-label">商品库存 <span class="tpl-form-line-small-title">Price</span></label>
                                        <div class="am-u-sm-9">
                                            <input type="text" id="link" placeholder="" name="kucun" value="{$result.kucun}" placeholder="请输入商品库存">
                                            <div>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="am-form-group">
                                        <label for="user-weibo" class="am-u-sm-3 am-form-label">商品积分 <span class="tpl-form-line-small-title">Price</span></label>
                                        <div class="am-u-sm-9">
                                            <input type="text" id="link" placeholder="" name="jifen" value="{$result.jifen}" placeholder="请输入商品积分">
                                            <div>
                                            </div>
                                        </div>
                                    </div>

                                    <div class="am-form-group">
                                        <label for="user-weibo" class="am-u-sm-3 am-form-label">商品图片 <span class="tpl-form-line-small-title">Images</span></label>
                                        <div class="am-u-sm-9">
                                            <div class="am-form-group am-form-file">
                                                <div class="tpl-form-file-img">
                                                    <img src="assets/img/a5.png" alt="">
                                                </div>
                                                <button type="button" class="am-btn am-btn-danger am-btn-sm">
                                                <i class="am-icon-cloud-upload"></i> 添加图片</button>
                                                <input id="doc-form-file" type="file" name="src" onchange="upimg(this)"><br>
                                                <div class="imgBox">
                                                    {volist name="result.src" id="val"}
                                                    <span>
                                                        <img src="{$val.0}" style="width:200px;height:120px;margin-top:10px;">
                                                        <input type="hidden" value="{$val.0}" name="src[]" class="img-src-value">
                                                        <input type="hidden" value="{$val.1}" name="thumb_src[]" class="img-thumb_src-value">
                                                        <span onclick="delBox(this)" class="am-close am-close-alt am-close-spin" style="position:relative;left:-10px;top:-50px;z-index:100; cursor:pointer;">&times;</span>
                                                    </span>
                                                    {/volist}
                                                </div>
                                            </div>

                                        </div>
                                    </div>

                                    <div class="am-form-group">
                                        <label for="user-intro" class="am-u-sm-3 am-form-label">描述内容</label>
                                        <div class="am-u-sm-9">
                                            <textarea name="abstract" class="" rows="5" id="user-intro" placeholder="请输入商品描述">{$result.abstract}</textarea>
                                        </div>
                                    </div>

                                    <div class="am-form-group">
                                        <div class="am-u-sm-9 am-u-sm-push-3">
                                            <button type="submit" class="am-btn am-btn-primary tpl-btn-bg-color-success ">提交</button>
                                        </div>
                                    </div>
                                </form>
                            </div>
                        </div>
                    </div>
                </div>



            </div>
        </div>
{/block}
{block name="footer-js"}
<script>
// function upimg(obj)
// {
// if( obj.value == "" ) {
//     return;
// }
// var formdata = new FormData(); 
// formdata.append("src" , $(obj)[0].files[0]);//获取文件法二
// $.ajax({
//     type : 'post',
//     url : "{:Url('admin/ad/upimg')}",
//     data : formdata,
//     cache : false,
//     processData : false, // 不处理发送的数据，因为data值是Formdata对象，不需要对数据做处理
//     contentType : false, // 不设置Content-type请求头
//     success : function(ret){
//     $('#img-view-box').attr('src', ret.src);
//     $('#img-value-box').val(ret.src);
//     $('#thumb-img-value-box').val(ret.thumb_src);

//         //alert(obj.value);
//     },
//     error : function(){ }
// });
// }   
function upimg(obj)
{
    if( obj.value == "" ) {
        return;
    }
    var formdata = new FormData(); 
    //<input type="file" name="img" />
    formdata.append("img" , $(obj)[0].files[0]);//获取文件法二
    $.ajax({
        type : 'post',
        url : "{:Url('admin/goods/upimg')}",
        data : formdata,
        cache : false,
        processData : false, // 不处理发送的数据，因为data值是Formdata对象，不需要对数据做处理
        contentType : false, // 不设置Content-type请求头
        success : function(ret){
            console.log(ret);
            var html = '<span><img src="'+ret.img+'" style="width:200px;height:120px;margin-top:10px;">';
                html += '<input type="hidden" value="'+ret.img+'" name="src[]" class="img-src-value">';
                html += '<input type="hidden" value="'+ret.img_thumb+'" name="thumb_src[]" class="img-thumb_src-value">' ;
                html += '<span onclick="delBox(this)" class="am-close am-close-alt am-close-spin" style="position:relative;left:-10px;top:-50px;z-index:100; cursor:pointer;">&times;</span></span>';
            $(".imgBox").append(html);
            },
        error : function(){ }
    });
}
function delBox(obj){
    $(obj).parent('span').remove();
}
</script>
{/block}